<?php
// Replace with real BROWSER API key from Google APIs
$apiKey = "AIzaSyACrZ5mWfwaID0Xahttng8ugdlvE5bwywA";

// Replace with real client registration IDs 
$regIDs = array("APA91bEMQS-O9zCSmxhZcYk6RZza5yzCHLMoS8D0Qe3jIyjXqRu35_6cwkykOvo4vcQVpMdCqVNM1TwsK1nPlKxixvVLcC4tAypi9LiggxxeLA5SbYtSHdHYDw4W97E64_t6R6Ue4IRjhjuYPymNCGQC0uGrQ2P-NA");

$time = time();
// Message to be sent
$message = '{"time":"'.$time.'","name":"alan","data":"http://wangmeng88.cn/","type":"url"}';

// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';

$fields = array(
                'registration_ids'  => $regIDs,
                'data'              => array( "msg" => $message ),
                );

$headers = array( 
                    'Authorization: key=' . $apiKey,
                    'Content-Type: application/json'
                );

// Open connection
$ch = curl_init();

// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );

curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );

// Execute post
$result = curl_exec($ch);

// Close connection
curl_close($ch);

echo $result;
?>